import Vue from 'vue'
import Router from 'vue-router'
import searchFlightPage from '@/pages/searchFlight/searchFlight.vue'
import orderManagePage from '@/pages/orderManage/orderManage.vue'
import bookFlightPage from '@/pages/bookFlight/bookFlight.vue'
import flightListPage from '@/pages/flightList/flightList.vue'
import flightListBackPage from '@/pages/flightListBack/flightList.vue'
import interBackPage from '@/pages/interBack/flightList.vue'
import selectCabinPage from '@/pages/cabin/cabin.vue'
import insurancePage from '@/pages/insurance/insurance.vue'
import insuranceExplainPage from '@/pages/insurance/insuranceExplain.vue'
import addPassengerPage from '@/pages/addPassenger/addPassenger.vue'
import editPassengerPage from '@/pages/editPassenger/editPassenger.vue'
import orderDetailPage from '@/pages/orderDetail/orderDetail.vue'
import insuranceDetailPage from '@/pages/orderDetail/insuranceDetail.vue'


import cityPage from '@/components/city/city.vue'
import datePage from '@/components/date/date.vue'
import help from '@/components/declaration/help.vue'
import bookingInformation from '@/components/declaration/bookingInformation.vue'
import DGRinformation from '@/components/declaration/DGRinformation.vue'
import endorse from '@/components/declaration/endorse.vue'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'search',                      //搜索页
      component: searchFlightPage
    },{
      path: '/order', 
      name: 'order',                       //订单管理页
      component: orderManagePage
    },{
      path: '/book',
      name: 'book',                        //机票预订页面
      component: bookFlightPage,
      beforeEnter:(to, from, next) => {
      	//如果是在拉卡拉支付页面未完成支付，回退至预定页面则跳转至订单列表页
      	//var pathArr = ['/cabin','/addPassenger','/editPassenger','/insurance','/endorse']
      	if(from.path == "/"){
      		next({ path: '/order'});
      	}else{
      		next()
      	}
      }
    },{
      path: '/flight',
      name: 'flight',                      //去程航班列表页
      component: flightListPage
    },{
      path: '/flightBack',
      name: 'flightBack',                  //国内回程航班列表页
      component: flightListBackPage
    },{
      path: '/interBack',
      name: 'interBack',                  //国际回程航班列表页
      component: interBackPage
    },{
      path: '/cabin',
      name: 'cabin',                       //选择舱位
      component: selectCabinPage
    },{
      path: '/insurance',                  //保险页
      name: 'insurance',
      component: insurancePage
    },{
      path: '/insuranceExplain',                  //保险说明页
      name: 'insuranceExplain',
      component: insuranceExplainPage
    },{
      path: '/addPassenger',               //新增乘机人
      name: 'addPassenger',
      component: addPassengerPage
    },{
      path: '/editPassenger',               //修改乘机人
      name: 'editPassenger',
      component: editPassengerPage
    },{
      path: '/orderDetail',                //订单详情
      name: 'orderDetail',
      component: orderDetailPage
    },{
      path: '/insuranceDetail',                //订单中的保险详情
      name: 'insuranceDetail',
      component: insuranceDetailPage
    },
    
    
    
    
    
    
    {
      path: '/city',                       //城市选择
      name: 'city',
      component: cityPage
    },{
      path: '/date',                       //日期选择
      name: 'date',
      component: datePage,
    },{
      path: '/help',                       //帮助中心
      name: 'help',
      component: help
    },{
      path: '/DGRinformation',             //危险品通知
      name: 'DGRinformation',
      component: DGRinformation
    },{
      path: '/bookingInformation',         //机票预订通知
      name: 'bookingInformation',
      component: bookingInformation
    },{
      path: '/endorse',                    //退改签说明
      name: 'endorse',
      component: endorse
    }
  ]
})
